package cn.framelife.rainbow.ui.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;

import cn.framelife.rainbow.ui.wizard.ReverseWizard;


/**
 * 打开JRainbow Reverse 导航
 * 
 * @author 潘广伟 p_3er@qq.com
 * @date 2013年11月7日 下午4:06:05
 * 
 */
public class ReverseExplorerOpenHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		ISelection selection = HandlerUtil.getCurrentSelection(event);
		ReverseWizard wizard = new ReverseWizard();
		wizard.init(window.getWorkbench(),
				selection instanceof IStructuredSelection ? (IStructuredSelection) selection
						: StructuredSelection.EMPTY);
		
		WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
		dialog.open();
		return null;
	}

}
